<template>
	<div class="show">
		<ul class="goodList">
			<li v-for="good in list">
				<img v-bind:src="good.img" />
				<p>{{ good.name }}lalalal</p>
			</li>
		</ul>
	</div>
</template>

<script>
export default {
	name: 'show',
	data() {
		return {
			list: []
		};
	},
	props: {
		code: Number,
		default: 0
	},
	methods:{
		update() {
			var _this = this;
			this.$http.get('json/data.json').then(function(res) {
				console.log('GoodList中接收到' + _this.code);
				var data = res.data.find(e => e.code === _this.code);
				if (data) {
					_this.list = data.data;
				} else {
					_this.list = [];
				}
			});
		}
	},watch: {
		code() {
			this.update();
		}
	},
	mounted() {
		this.update();
	},
	
};
</script>

<style>
.goodList li {
	list-style: none;
	width: 12.5rem;
	font-size: 0.5625rem;
	float: left;
	margin-bottom: 1.875rem;
}
.goodList img {
	width: 11.25rem;
}
</style>
